﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;
using FisheryPlatform.Bussiness.Cache;

namespace FisheryPlatform.Bussiness.WebRuntime
{
    public class StaticHtmlRenderHandler : IHttpHandler
    {
        #region IHttpHandler 成员

        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;

            //var fileName = Path.GetFileNameWithoutExtension(request.Url.AbsolutePath);
            if (request.Url.Segments.Length >= 2)
            {
                switch (request.Url.Segments[1].Trim('/').ToLower())
                {
                    case "p":
                        response.Write(ProductStaticHtmlCache.Get(request.Url.AbsolutePath.Replace("/p","")));
                        break;
                    case "n":
                        response.Write(PostStaticHtmlCache.Get(request.Url.AbsolutePath.Replace("/n", "")));
                        break;
                }
            }

            response.End();
        }

        #endregion
    }
}
